//
//  FirstViewController.swift
//  YiDa
//
//  Created by zhoufei on 16/6/26.
//  Copyright © 2016年 ZhouFei. All rights reserved.
//

import UIKit

class FirstViewController: UIViewController,UIWebViewDelegate {

    @IBOutlet weak var loading: UIActivityIndicatorView!
    @IBOutlet weak var webView: UIWebView!
    var isWillLogin = true
    override func viewDidLoad() {
        super.viewDidLoad()
        
        
        // Do any additional setup after loading the view, typically from a nib.
    }
    
    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        if YiDaUser.main.isLogin(){
            if isWillLogin{
                webView.delegate = self
                print(YiDaUser.main.userId!)
                webView.loadRequest(NSURLRequest(URL: NSURL(string: "http://tm.digicircles.com/index.php/Home/Index/index/\(YiDaUser.main.userId!)/0")!))
                isWillLogin = false
            }
            
        }
    }
    
    func webViewDidStartLoad(webView: UIWebView) {
        print("start")
        self.loading.startAnimating()
    }
    
    func webView(webView: UIWebView, didFailLoadWithError error: NSError?) {
        print("faile")
        self.loading.stopAnimating()
    }
    
    func webViewDidFinishLoad(webView: UIWebView) {
        print("finish")
        self.loading.stopAnimating()
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

